package com.gqzm.side.common.result;

import lombok.experimental.UtilityClass;


/**
 * @ClassName: {@link StringCamelUtils}
 * @description: 下划线-驼峰命名工具类
 * @author: peter qin
 * @date: 2023 07 17
 * @version: 1.0
 **/
@UtilityClass
public class StringCamelUtils {

    public static String underlineToCamel(String input) {
        if (input == null || !input.contains("_")) {
            return input;
        }
        StringBuilder result = new StringBuilder();
        String[] words = input.split("_");
        for (String word : words) {
            if (result.length() == 0) {
                result.append(word.toLowerCase());
            } else {
                result.append(Character.toUpperCase(word.charAt(0)))
                        .append(word.substring(1).toLowerCase());
            }
        }
        return result.toString();
    }

}
